var d = Object.defineProperty;
var T = (t, r, n) => r in t ? d(t, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[r] = n;
var S = (t, r, n) => (T(t, typeof r != "symbol" ? r + "" : r, n), n);
const y = new class {
  constructor() {
    /**
     * 事件
     */
    S(this, "event", /* @__PURE__ */ new Map());
  }
  /**
   * @description: 通知
   * @param {string} id ID
   * @param {...array} parameter 参数
   * @return {void}
   */
  emit(r, ...n) {
    const e = this.event.get(r);
    e && e.forEach((s) => s(...n));
  }
  /**
   * @description: 监听
   * @param {string} id ID
   * @param {Func} func 回调
   * @return {void}
   */
  on(r, n) {
    var e;
    this.event.has(r) || this.event.set(r, []), (e = this.event.get(r)) == null || e.push(n);
  }
  /**
   * @description: 取消监听
   * @param {string} id ID
   * @param {Func} func 回调
   *
   * 取消所有的订阅 都不传递
   *
   * 针对名称下所有的函数取消订阅 只传递id
   *
   * 针对名称和函数取消订阅 传递id和func
   *
   * @return {void}
   */
  off(r, n) {
    if (!r && !n) {
      this.event.clear();
      return;
    }
    if (!r)
      return;
    const e = this.event.get(r);
    if (!e)
      return;
    if (!n) {
      this.event.delete(r);
      return;
    }
    const s = [];
    for (let i = 0; i < e.length; i++)
      e[i].toString() !== n.toString() && s.push(e[i]);
    s.length > 0 ? this.event.set(r, s) : this.event.delete(r);
  }
  /**
   * @description: 查询已订阅的名称数量
   * @param {string} id ID
   *
   * 查询已订阅的名称数量 不传递id
   *
   * 查询某个名称下的订阅数量 传递id
   *
   * @return {number}
   */
  getSize(r) {
    if (typeof r != "string")
      return this.event.size;
    const n = this.event.get(r);
    return n ? n.length : 0;
  }
}();
class B {
  constructor() {
    /**
     * 队列列表
     */
    S(this, "task", []);
    /**
     * 执行状态
     */
    S(this, "status", !1);
  }
  /**
   * 加入新的任务
   */
  push(r) {
    this.task.push(r), this.execute();
  }
  /**
   * 获取当前任务数量
   */
  getSize() {
    return this.task.length;
  }
  /**
   * 执行下一个任务
   */
  execute() {
    this.task.length <= 0 || this.status || (this.status = !0, this.task[0](() => {
      this.status = !1, this.task.splice(0, 1), this.execute();
    }));
  }
}
function N(t, r = 200, n = !1) {
  let e;
  return function() {
    e || (n ? (t.apply(null, arguments), e = globalThis.setTimeout(() => e = void 0, r)) : e = globalThis.setTimeout(() => {
      t.apply(null, arguments), e = void 0;
    }, r));
  };
}
function w(t, r = 200, n = !1) {
  let e;
  return function() {
    e || (n && t.apply(null, arguments), e = globalThis.setTimeout(() => {
      n || t.apply(null, arguments), e = void 0;
    }, r));
  };
}
async function D(t = 0) {
  if (!(typeof t != "number" || t <= 0))
    return new Promise(function(r) {
      setTimeout(r, t);
    });
}
const a = function(t) {
  const n = Object.prototype.toString.call(t).replace(/\[|]|object|\s/g, "").toLocaleLowerCase();
  return n !== "number" ? n : isNaN(t) ? "nan" : n;
}, f = {
  /**
   * @description: 获取某个数据类型
   * @param {any} v 数据
   * @return {DataType} 数据类型
   */
  getDataType: a,
  /**
   * @description: 判断数据类型是否是 string
   * @param {any} v 数据
   * @return {boolean} 是否符合
   */
  isString(t) {
    return a(t) === "string";
  },
  /**
   * @description: 判断数据类型是否是 number
   * @param {any} v 数据
   * @return {boolean} 是否符合
   */
  isNumber(t) {
    return a(t) === "number";
  },
  /**
   * @description: 判断数据类型是否是 bigint
   * @param {any} v 数据
   * @return {boolean} 是否符合
   */
  isBigint(t) {
    return a(t) === "bigint";
  },
  /**
   * @description: 判断数据类型是否是 array
   * @param {any} v 数据
   * @return {boolean} 是否符合
   */
  isArray(t) {
    return a(t) === "array";
  },
  /**
   * @description: 判断数据类型是否是 object
   * @param {any} v 数据
   * @return {boolean} 是否符合
   */
  isObject(t) {
    return a(t) === "object";
  },
  /**
   * @description: 判断数据类型是否是 symbol
   * @param {any} v 数据
   * @return {boolean} 是否符合
   */
  isSymbol(t) {
    return a(t) === "symbol";
  },
  /**
   * @description: 判断数据类型是否是 function
   * @param {any} v 数据
   * @return {boolean} 是否符合
   */
  isFunction(t) {
    return a(t) === "function";
  },
  /**
   * @description: 判断数据类型是否是 date
   * @param {any} v 数据
   * @return {boolean} 是否符合
   */
  isDate(t) {
    return a(t) === "date";
  },
  /**
   * @description: 判断数据类型是否是 boolean
   * @param {any} v 数据
   * @return {boolean} 是否符合
   */
  isBoolean(t) {
    return a(t) === "boolean";
  },
  /**
   * @description: 判断数据类型是否是 null
   * @param {any} v 数据
   * @return {boolean} 是否符合
   */
  isNull(t) {
    return a(t) === "null";
  },
  /**
   * @description: 判断数据类型是否是 undefined
   * @param {any} v 数据
   * @return {boolean} 是否符合
   */
  isUndefined(t) {
    return a(t) === "undefined";
  },
  /**
   * @description: 判断数据类型是否是 nan
   * @param {any} v 数据
   * @return {boolean} 是否符合
   */
  isNan(t) {
    return a(t) === "nan";
  }
};
function p(t, r = "up") {
  t += 1;
  let n = "";
  for (; t > 0; ) {
    let e = t % 26;
    e = e === 0 ? e = 26 : e, n = String.fromCharCode(96 + parseInt(e)) + n, t = (t - e) / 26;
  }
  return r === "down" ? n : n.toLocaleUpperCase();
}
const b = function(t, r) {
  const n = Math.min(t, r), s = Math.max(t, r) - n;
  return s === 0 ? n : Math.floor(Math.random() * (s + 1)) + n;
}, L = {
  number: b,
  /**
   * @description: 生成随机ID
   * @return {string}
   */
  id() {
    return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
      /[xy]/g,
      function(t) {
        let r = Math.random() * 16 | 0;
        return (t === "x" ? r : r & 3 | 8).toString(16);
      }
    );
  },
  /**
   * @description: 生成随机字母
   * @param {number} count 字母长度 默认5 非必填
   * @param {"smallLetter" | "capitalization" | "mix"} type 字母类型 默认smallLetter 非必填
   * 
   * smallLetter 小写
   * 
   * capitalization 大写
   * 
   * mix 混合
   * 
   * @return {string}
   */
  english(t = 5, r = "smallLetter") {
    return Array.from({ length: t }).map(function() {
      const n = p(Math.floor(Math.random() * 26));
      return r === "capitalization" || r === "mix" && b(1, 2) === 1 ? n : n.toLocaleLowerCase();
    }).join("");
  },
  /**
   * @description: 生成随机中文
   * @param {number} count 字母长度 默认5 非必填
   * @return {string}
   */
  chinese(t = 5) {
    const r = [];
    for (let n = 0; n < t; n++) {
      let e = "";
      e = "\\u" + (Math.floor(Math.random() * (40869 - 19968)) + 19968).toString(16), e = unescape(e.replace(/\\u/g, "%u")), r.push(e);
    }
    return r.join("");
  }
};
function O(t) {
  t = t.toLocaleUpperCase();
  let r = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", n = 0;
  for (let e = 0, s = t.length - 1; e < t.length; e += 1, s -= 1)
    n += Math.pow(r.length, s) * (r.indexOf(t[e]) + 1);
  return Math.max(0, n - 1);
}
const x = ["B", "KB", "MB", "GB", "TB"];
function j(t, r = "B") {
  let n = 0;
  const e = x.indexOf(r) === -1 ? x[0] : r;
  f.isNumber(t) && t > 0 && (n = t);
  function s(i, o = 0) {
    return o = Math.floor(o), !f.isNumber(o) || !o || !(o > 0) ? Math.floor(i) : Number(i.toFixed(o));
  }
  return {
    /**
     * @description: 转换
     * @param {StorageUnit} unit 转换后的单位
     * @param {number} decimalCount 保留几位小数 默认0 非必填
     * @return {number}
     */
    convert(i, o = 0) {
      if (n <= 0)
        return 0;
      const g = x.indexOf(i) === -1 ? x[0] : i, h = x.indexOf(e), l = x.indexOf(g);
      if (h === -1 || l === -1)
        return 0;
      let c = 0;
      if (h === l)
        c = t;
      else if (h < l) {
        const M = l - h;
        for (let m = 0; m < M; m++)
          t /= 1024;
        c = t;
      } else if (h > l) {
        const M = h - l;
        for (let m = 0; m < M; m++)
          t *= 1024;
        c = t;
      }
      return o = Math.floor(o), !f.isNumber(o) || !o || !(o > 0) ? Math.floor(c) : Number(c.toFixed(o));
    },
    /**
     * @description: 自动转换
     * @param {number} decimalCount 保留几位小数 默认0 非必填
     * @return {string} 转后的值，保留存储单位
     */
    auto(i = 0) {
      if (n < 1024)
        return `${n}${e}`;
      const o = x.indexOf(e);
      for (let g = o; g > 0; g--)
        n *= 1024;
      return n < 1024 ? `${s(Math.max(0, n), i)}B` : n < 1024 * 1024 ? `${s(n / 1024, i)}KB` : n < 1024 * 1024 * 1024 ? `${s(n / 1024 / 1024, i)}MB` : n < 1024 * 1024 * 1024 * 1024 ? `${s(n / 1024 / 1024 / 1024, i)}GB` : `${s(n / 1024 / 1024 / 1024 / 1024, i)}TB`;
    }
  };
}
function Y(t, r) {
  return !f.isString(t) || !t ? "" : (r = Math.max(
    -1,
    f.isNumber(r) ? Math.floor(r) : -1
  ), r <= 0 ? t : t.length > r ? t.substring(0, r) + "..." : t);
}
const I = {
  /**
   * @description: 校验内容是否是字符串，并且不为空，你也可以自定义字符串的长度范围
   * @param {any} value 内容
   * @param {number} options.min 非必传，默认1，传递时需保证大于等于1，不符合按1处理
   * @param {number} options.max 非必传，大于等于options.min即可
   * @return {*}
   */
  string(t, r) {
    if (!f.isString(t) || t === "")
      return !1;
    f.isObject(r) || (r = {});
    const n = Math.max(1, (r == null ? void 0 : r.min) || 1);
    return t.length < n ? !1 : r && r.max && f.isNumber(r.max) && r.max > n ? !(t.length > r.max) : !0;
  }
}, u = function(t, r, n) {
  return t.includes(r) ? (t = t.replace(r, n), u(t, r, n)) : t;
};
function F(t = /* @__PURE__ */ new Date()) {
  class r extends Date {
    format(e = "") {
      return f.isString(e) || (e = ""), e ? (e = u(e, "YYYY", () => this.getFullYear().toString()), e = u(e, "YY", () => this.getFullYear().toString().slice(-2)), e = u(e, "MM", () => (this.getMonth() + 1).toString().padStart(2, "0")), e = u(e, "M", () => (this.getMonth() + 1).toString()), e = u(e, "DD", () => this.getDate().toString().padStart(2, "0")), e = u(e, "D", () => this.getDate().toString()), e = u(e, "hh", () => this.getHours().toString().padStart(2, "0")), e = u(e, "h", () => this.getHours().toString()), e = u(e, "mm", () => this.getMinutes().toString().padStart(2, "0")), e = u(e, "m", () => this.getMinutes().toString()), e = u(e, "ss", () => this.getSeconds().toString().padStart(2, "0")), e = u(e, "s", () => this.getSeconds().toString()), e = u(e, "SSS", () => this.getTime().toString().slice(-3)), e = u(e, "SS", () => this.getTime().toString().slice(-3, -1)), e = u(e, "S", () => this.getTime().toString().slice(-3, -2)), e) : this.toDateString();
    }
    /**
     * @description: 时间前后，传入时间得到多少时间前或多少时间后
     * @param {number} config.minSecond 小于多少秒后得到刚刚，默认10秒
     * @param {number} config.contrastTime 对比时间，默认当前时间戳
     * @return {string} 之前或之后的时间
     */
    ft(e) {
      e = Object.assign({ minSecond: 10, contrastTime: (/* @__PURE__ */ new Date()).getTime() }, e || {}), e.minSecond = Math.max(59, e.minSecond), console.log(this);
      const s = this.getTime(), i = e.contrastTime < s ? "后" : "前", o = Math.floor(Math.abs(e.contrastTime - s) / 1e3);
      if (o <= e.minSecond)
        return "刚刚";
      if (o < 60)
        return o + "秒" + i;
      const g = o / 60;
      if (g < 60)
        return Math.floor(g) + "分钟" + i;
      const h = g / 24;
      if (h < 24)
        return Math.floor(h) + "小时" + i;
      const l = h / 24;
      if (l < 30)
        return Math.floor(l) + "天" + i;
      const c = l / 30;
      return c < 12 ? Math.floor(c) + "个月" + i : Math.floor(c / 12) + "年" + i;
    }
  }
  return new r(t);
}
const v = {
  version: "1.0.5",
  eventBus: y,
  queue: B,
  throttle: N,
  debounce: w,
  wait: D,
  type: f,
  random: L,
  indexToLetter: p,
  letterToIndex: O,
  storageConversion: j,
  stringEllipsis: Y,
  verification: I,
  date: F
};
export {
  v as default
};
